<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    template="/WEB-INF/templates/layoutCourtier.xhtml">


    <ui:define name="content">

        <p:panel header="#{msgs.titrePanelPrincipal}"
            style="width:1200px;height:800px;">

            <p:panel style="width:100%;height:100%;">

                <h:panelGrid columns="2" cellpadding="2" border="1">

                    <p:graphicImage value="images/network2.png" />

                    <h:outputText
                        value="___________#{manage.serviceClient.tousLesAssureurs[0].raisonSociale}___________" />

                </h:panelGrid>
            </p:panel>
            <h:form>
                <p:commandButton image="ui-icon ui-icon-star" immediate="true"
                    style="width:120px" value="logout" action="#{manage.logout}"
                    ajax="false" />

                <p:commandButton image="ui-icon ui-icon-star" immediate="true"
                    style="width:120px" value="#{msgs.accueil}" action="versaccueil"
                    ajax="false" />

                <p:spacer width="100" height="10" />
            
            </h:form>


            <h:form>
                <p:separator id="customSeparator1" style="width:190px;height:10px" />

                <h:outputLabel value="#{msgs.recherchePolice} : " />
                <p:inputText
                    value="#{manage.serviceClient.recherchePolicesAssureurId}">
                </p:inputText>

                <p:commandButton value="#{msgs.recherche}"
                    image="ui-icon ui-icon-search" action="#{manage.policesAssureurId}" />

                <p:commandButton value="#{msgs.toutesLesPolices}"
                    image="ui-icon ui-icon-search"
                    action="#{manage.annuleRecherchePolicesAssureurId}" />

                <p:separator id="customSeparator2" style="width:190px;height:10px" />

            </h:form>

            <h:form>

                <p:dataTable var="police" widgetVar="police"
                    rowStyleClass="#{police.actif?null:'sup'}"
                    emptyMessage="Pas de police correspondant au critère de recherche"
                    value="#{manage.serviceClient.policesAssureurId}" paginator="true"
                    rows="3" rowKey="#{police.key}" selection="#{manage.policeChoisie}"
                    selectionMode="single"
                    paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} 
            {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                    rowsPerPageTemplate="3,10,15">

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.numero}" />
                        </f:facet>
                        <h:outputText value="#{police.numeroPolice}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.client}" />
                        </f:facet>
                        <h:outputText value="#{police.client.raisonSociale}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.dateDebut}" />
                        </f:facet>
                        <h:outputText value="#{police.dateDebut}">
                            <f:convertDateTime pattern="dd/MM/yyyy" timeZone="Europe/Paris" />

                        </h:outputText>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.dateFin}" />

                        </f:facet>
                        <h:outputText value="#{police.dateFin}">
                            <f:convertDateTime pattern="dd/MM/yyyy" timeZone="Europe/Paris" />
                        </h:outputText>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.prime}" />
                        </f:facet>
                        <h:outputText value="#{police.prime}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.total}" />
                        </f:facet>
                        <h:outputText value="#{manage.total(police)}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value=" #{msgs.graphique} " />
                        </f:facet>
                        <p:barChart value="#{manage.categoryModel(police)}"
                            style="height:100px;" title="Prime/Indemnités" stacked="false"
                            barMargin="100" min="0"
                            max="#{manage.hauteurGraphique(police.prime)}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.statut}" />
                        </f:facet>
                        <h:outputText value="#{police.statut}" />
                    </p:column>

                    <f:facet name="footer">
                        <p:commandButton value="#{msgs.listeSinistres}"
                            image="ui-icon ui-icon-search" oncomplete="sinistres.show()" update="display1"
                            action="#{manage.boutonModifierPolice}" />


                        <p:dialog widgetVar="sinistres" resizable="false" width="900"
                            showEffect="clip" hideEffect="fold">
<h:panelGrid id="display1">
                            <p:dataTable var="sinistre" value="#{manage.sinistresPolice}"
                                paginator="true" rowStyleClass="#{sinistre.actif?null:'sup'}"
                                widgetVar="sinistre"
                                emptyMessage="Pas de sinistre au critère de recherche" rows="10"
                                rowKey="#{sinistre.key}" selection="#{manage.sinistreChoisi}"
                                selectionMode="single"
                                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} 
            {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                rowsPerPageTemplate="5,10,15">


                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{msgs.police}" />
                                    </f:facet>
                                    <h:outputText value="#{sinistre.police.numeroPolice}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{msgs.client}" />
                                    </f:facet>
                                    <h:outputText value="#{sinistre.police.client.raisonSociale}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{msgs.assureur}" />
                                    </f:facet>
                                    <h:outputText value="#{sinistre.police.assureur.raisonSociale}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{msgs.numero}" />
                                    </f:facet>
                                    <h:outputText value="#{sinistre.numeroSinistre}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{msgs.prenom}" />
                                    </f:facet>
                                    <h:outputText value="#{sinistre.prenom}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{msgs.nom}" />
                                    </f:facet>
                                    <h:outputText value="#{sinistre.nom}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{msgs.debutPeriode}" />
                                    </f:facet>
                                    <h:outputText value="#{sinistre.dateDebut}">
                                        <f:convertDateTime pattern="dd/MM/yyyy"
                                            timeZone="Europe/Paris" />
                                    </h:outputText>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{msgs.finPeriode}" />
                                    </f:facet>
                                    <h:outputText value="#{sinistre.dateFin}">
                                        <f:convertDateTime pattern="dd/MM/yyyy"
                                            timeZone="Europe/Paris" />
                                    </h:outputText>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{msgs.indemnite}" />
                                    </f:facet>
                                    <h:outputText value="#{sinistre.indemnite}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{msgs.statut}" />
                                    </f:facet>
                                    <h:outputText value="#{sinistre.statut}" />
                                </p:column>


                            </p:dataTable>


</h:panelGrid>
                        </p:dialog>

                    </f:facet>

                </p:dataTable>

            </h:form>
        </p:panel>
    </ui:define>
</ui:composition>